﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="dnTaoMoiTB.ascx.cs" Inherits="uicontrol_dnTaoMoiTB" %>
<script type="text/javascript" src="../App_Themes/function.js"></script>
<asp:SqlDataSource ID="dsTenDN" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>"
    DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:evaConn.ProviderName %>"
    SelectCommand="SELECT MaDoanhNghiep, TenDoanhNghiep FROM DoanhNghiep WHERE (Status = 1) AND (MaDoanhNghiep = @MaDoanhNghiep) ORDER BY TenDoanhNghiep">
    <SelectParameters>
        <asp:SessionParameter Name="MaDoanhNghiep" SessionField="CompanyID" />
    </SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsLacHau" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>"
    DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:evaConn.ProviderName %>"
    SelectCommand="SELECT [LacHau], [Description] FROM [LacHau]"></asp:SqlDataSource>
<asp:SqlDataSource ID="dsDSTB" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>" ProviderName="<%$ ConnectionStrings:evaConn.ProviderName %>"
    SelectCommand="SELECT ThietBi.MaThietBi, ThietBi.TenThietBi, ThietBi.NamSanXuat, ThietBi.NoiSanXuat, ThietBi.NangSuat, ThietBi.MaDoanhNghiep, LacHau.Description FROM ThietBi INNER JOIN LacHau ON ThietBi.LacHau = LacHau.LacHau WHERE (ThietBi.MaDoanhNghiep = @MaDoanhNghiep) AND (ThietBi.Status = 1)" 
    DeleteCommand="UPDATE ThietBi SET Status=0 WHERE MaThietBi = @MaThietBi" 
    UpdateCommand="UPDATE ThietBi SET TenThietBi = @TenThietBi, NamSanXuat = @NamSanXuat, NoiSanXuat = @NoiSanXuat, NangSuat = @NangSuat, LacHau = @LacHau, MaDoanhNghiep = @MaDoanhNghiep WHERE (MaThietBi = @MaThietBi)">
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlDN" DefaultValue="0" Name="MaDoanhNghiep" PropertyName="SelectedValue" />
    </SelectParameters>
    <DeleteParameters>
        <asp:SessionParameter Name="MaThietBi" SessionField="MaThietBi" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="TenThietBi" />
        <asp:Parameter Name="NamSanXuat" />
        <asp:Parameter Name="NoiSanXuat" />
        <asp:Parameter Name="NangSuat" />
        <asp:Parameter Name="LacHau" />
        <asp:Parameter Name="MaDoanhNghiep" />
        <asp:SessionParameter Name="MaThietBi" SessionField="MaThietBi" />
    </UpdateParameters>
</asp:SqlDataSource>
 
<table class="hero-unit form-horizontal">
    <tr>
<td colspan="3"><asp:Label ID="DNTaoTb" Text="TẠO MỚI THIẾT BỊ" runat="server" CssClass="LabelTitle"></asp:Label></div>
    </tr>
    <tr>
        <td style="width:30%">
            <asp:Label ID="Label1" runat="server" Text="Tên Thiết bị" CssClass="Label"></asp:Label></td>
        <td style="width:40%">
            <asp:TextBox ID="txtTenTB" runat="server" CssClass="Textbox" MaxLength="500" TabIndex="1"></asp:TextBox></td>
        <td>&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="ValidateLabel"
                ErrorMessage="Không được trống" ControlToValidate="txtTenTB" Display="Dynamic"></asp:RequiredFieldValidator></td></tr>
    <tr>
        <td style="height: 25px">
            <asp:Label ID="Label2" runat="server" CssClass="Label" Text="Tên Doanh nghiệp"></asp:Label></td>
        <td style="height: 25px">
            <asp:DropDownList ID="ddlDN" runat="server" CssClass="DropdownList" DataSourceID="dsTenDN" DataTextField="TenDoanhNghiep" DataValueField="MaDoanhNghiep" TabIndex="2" AutoPostBack="True" OnSelectedIndexChanged="ddlDN_SelectedIndexChanged">
            </asp:DropDownList></td>
        <td style="height: 25px">
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label3" runat="server" CssClass="Label" Text="Năm Sản xuất"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtNamSX" runat="server" CssClass="Textbox" MaxLength="4" TabIndex="3"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="ValidateLabel"
                ErrorMessage="Không được trống" ControlToValidate="txtNamSX" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtNamSX"
                CssClass="ValidateLabel" Display="Dynamic" ErrorMessage="Năm SX không hợp lệ"
                ValidationExpression="([1][9][0-9][0-9])|([2][0-1][0-9][0-9])"></asp:RegularExpressionValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label4" runat="server" CssClass="Label" Text="Nơi Sản xuất"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtNoiSX" runat="server" CssClass="Textbox" MaxLength="500" TabIndex="4"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="ValidateLabel"
                ErrorMessage="Không được trống" ControlToValidate="txtNoiSX" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label5" runat="server" CssClass="Label" Text="Năng suất"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtNangSuat" runat="server" CssClass="Textbox" MaxLength="255" TabIndex="5"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" CssClass="ValidateLabel"
                ErrorMessage="Không được trống" ControlToValidate="txtNangSuat" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label6" runat="server" CssClass="Label" Text="Tình trạng TB"></asp:Label></td>
        <td>
            <asp:DropDownList ID="ddlTinhTrang" runat="server" CssClass="DropdownList" TabIndex="6" DataSourceID="dsLacHau" DataTextField="Description" DataValueField="LacHau">
            </asp:DropDownList></td>
        <td>
        </td>
    </tr>
    
    <tr>
        <td></td>
        <td>
            <asp:Button ID="btnNew" class="btn btn-primary" runat="server"  TabIndex="7" Text="Tạo mới" OnClick="btnNew_Click" />
            <asp:Button ID="btnEdit" class="btn btn-primary" runat="server"  TabIndex="7" Text="Cập nhật" OnClick="btnEdit_Click" Visible="False" /> 
         
            <asp:Button ID="btnCancel" runat="server" CausesValidation="False"  class="btn" 
                TabIndex="8" Text="Làm lại" OnClick="btnCancel_Click" /> 
         
        </td>
        <td></td>
    </tr>
</table>
&nbsp;
<asp:Panel ID="pnlDSTB" runat="server" >
    <asp:Label ID="lblNotify" runat="server" CssClass="LabelResult"></asp:Label>
    <asp:GridView ID="grvDSTB" runat="server" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" OnRowDataBound="grvDSTB_RowDataBound" OnPageIndexChanging="grvDSTB_PageIndexChanging" OnRowDeleting="grvDSTB_RowDeleting" OnRowEditing="grvDSTB_RowEditing" class="table">
        <Columns>
            <asp:BoundField DataField="MaThietBi" HeaderText="MaThietBi" InsertVisible="False"
                ReadOnly="True" SortExpression="MaThietBi" />
            <asp:BoundField DataField="TenThietBi" HeaderText="T&#234;n thiết bị" SortExpression="TenThietBi" >
                <HeaderStyle Width="30%" />
            </asp:BoundField>
            <asp:BoundField DataField="NamSanXuat" HeaderText="Năm sản xuất" SortExpression="NamSanXuat" >
                <HeaderStyle Width="10%" />
            </asp:BoundField>
            <asp:BoundField DataField="NoiSanXuat" HeaderText="Nơi sản xuất" SortExpression="NoiSanXuat" >
                <HeaderStyle Width="20%" />
            </asp:BoundField>
            <asp:BoundField DataField="NangSuat" HeaderText="Năng suất" SortExpression="NangSuat" >
                <HeaderStyle Width="10%" />
            </asp:BoundField>
            <asp:BoundField DataField="MaDoanhNghiep" HeaderText="MaDoanhNghiep" SortExpression="MaDoanhNghiep" />
            <asp:BoundField DataField="Description" HeaderText="T&#236;nh trạng" SortExpression="Description" >   
                <HeaderStyle Width="20%" />             
            </asp:BoundField>
            <asp:CommandField ButtonType="Image" DeleteImageUrl="~/App_Themes/Default/Css/images/delete.gif"
                DeleteText="X&#243;a" EditImageUrl="~/App_Themes/Default/Css/images/edit.gif"
                EditText="Sửa" HeaderText="Chức năng" ShowDeleteButton="True" ShowEditButton="True" />
        </Columns>
            <PagerStyle CssClass="GrvPagerStyle"/>
            <HeaderStyle CssClass="GrvHeader" />
            <RowStyle CssClass="GrvRowStyle"/>
            <AlternatingRowStyle CssClass="GrvAlternatingRowStyle" /> 
    </asp:GridView>
</asp:Panel>
